/**
 * 
 */
package exo2;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
        

/**
 * http://docs.oracle.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html
 * 
 * 

#!/bin/sh

echo "start server"

java -classpath /home/fcamps/workspace/GMM/bin/ -Djava.rmi.server.codebase=file:/home/fcamps/workspace/GMM/bin/ exo2.Server &

echo "start client"

java  -classpath  /home/fcamps/workspace/GMM/bin/ exo2.Client



http://docs.oracle.com/javase/tutorial/rmi/running.html

sur un serveur distant :

serveur :


java -cp /home/ann/src:/home/ann/public_html/classes/compute.jar
     -Djava.rmi.server.codebase=http://mycomputer/~ann/classes/compute.jar
     -Djava.rmi.server.hostname=mycomputer.example.com
     -Djava.security.policy=server.policy
        engine.ComputeEngine


 * 
 * 
 * @author fcamps
 *
 */


public class Server implements Hello {
        
    public Server() {}

    public String sayHello() {
        return "Hello, world!";
    }
        
    public static void main(String args[]) {
        
        try {
            Server obj = new Server();
            Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);

            // Bind the remote object's stub in the registry
            Registry registry = LocateRegistry.getRegistry();
            registry.bind("Hello", stub);

            System.err.println("Server ready");
        } catch (Exception e) {
            System.err.println("Server exception: " + e.toString());
            e.printStackTrace();
        }
    }
}